package com.ag.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.admin.dao.TbCurrentEventDAO;
import com.ag.admin.service.ICurrentEventService;
import com.ag.bean.TbCurrentEvent;
import com.ag.lzm.dao.BaseDAO;

@Service("LZMCurrentEventServiceImpl")
public class CurrentEventServiceImpl implements ICurrentEventService {
	@Resource(name = "LZMTbCurrentEventDAO")
	private TbCurrentEventDAO currentEventDAO;
	/**
	 * 2010年9月26日开始启用BaseDAO
	 */
	@Resource(name = "LZMBaseDAO")
	private BaseDAO baseDAO;

	@Override
	public List<TbCurrentEvent> findCurrentEvent() {
		String queryString = "from TbCurrentEvent ce join fetch ce.tbEvent";
		return baseDAO.find(queryString);
	}

	/**
	 * 返回false如果不是处于应急 返回true处于应急
	 */
	@Override
	public boolean checkEmergency() {
		String queryString = "select count(*) from TbCurrentEvent";
		if (0 == (Long) baseDAO.find(queryString).get(0)) {
			return false;
		}
		return true;
	}

}
